package com.example.service;

import com.example.entity.Shoucang;
import com.example.mapper.ShoucangMapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ShoucangService {
    @Resource
    ShoucangMapper shoucangMapper;
    public void  add(Shoucang shoucang) {
            shoucangMapper.insert(shoucang);
    }

    public void delete(Shoucang shoucang) {
        shoucangMapper.deleteById(shoucang);
    }

    public void update(Shoucang shoucang) {
        shoucangMapper.updateById(shoucang);
    }

    public List<Shoucang> selectAll(Shoucang shoucang) {
      return  shoucangMapper.selectAll(shoucang);
    }

    public PageInfo<Shoucang> selectPage(Integer pageNum, Integer pageSize, Shoucang shoucang) {
        PageHelper.startPage(pageNum, pageSize);
        List<Shoucang> list = shoucangMapper.selectAll(shoucang);
        return PageInfo.of(list);
    }
}
